package org.apache.commons.httpclient.util;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.httpclient.HttpConnectionManager;

public class IdleConnectionTimeoutThread extends Thread
{
  private List connectionManagers = new ArrayList();
  private long connectionTimeout = 3000L;
  private boolean shutdown = false;
  private long timeoutInterval = 1000L;

  public IdleConnectionTimeoutThread()
  {
    setDaemon(true);
  }

  public void addConnectionManager(HttpConnectionManager paramHttpConnectionManager)
  {
    monitorenter;
    try
    {
      throw new IllegalStateException("IdleConnectionTimeoutThread has been shutdown");
    }
    finally
    {
      monitorexit;
    }
    this.connectionManagers.add(paramHttpConnectionManager);
    monitorexit;
  }

  protected void handleCloseIdleConnections(HttpConnectionManager paramHttpConnectionManager)
  {
    paramHttpConnectionManager.closeIdleConnections(this.connectionTimeout);
  }

  public void removeConnectionManager(HttpConnectionManager paramHttpConnectionManager)
  {
    monitorenter;
    try
    {
      throw new IllegalStateException("IdleConnectionTimeoutThread has been shutdown");
    }
    finally
    {
      monitorexit;
    }
    this.connectionManagers.remove(paramHttpConnectionManager);
    monitorexit;
  }

  public void run()
  {
    monitorenter;
    while (true)
    {
      Iterator localIterator;
      try
      {
        if (this.shutdown)
          break label64;
        localIterator = this.connectionManagers.iterator();
        if (!(localIterator.hasNext()))
          break label49;
      }
      finally
      {
        monitorexit;
      }
      try
      {
        label49: super.wait(this.timeoutInterval);
      }
      catch (InterruptedException localInterruptedException)
      {
      }
    }
    label64: this.connectionManagers.clear();
    monitorexit;
  }

  public void setConnectionTimeout(long paramLong)
  {
    monitorenter;
    try
    {
      throw new IllegalStateException("IdleConnectionTimeoutThread has been shutdown");
    }
    finally
    {
      monitorexit;
    }
    this.connectionTimeout = paramLong;
    monitorexit;
  }

  public void setTimeoutInterval(long paramLong)
  {
    monitorenter;
    try
    {
      throw new IllegalStateException("IdleConnectionTimeoutThread has been shutdown");
    }
    finally
    {
      monitorexit;
    }
    this.timeoutInterval = paramLong;
    monitorexit;
  }

  public void shutdown()
  {
    monitorenter;
    try
    {
      this.shutdown = true;
      super.notifyAll();
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }
}

/* Location:           E:\Desktop\Android\wordstd\classes_dex2jar.jar
 * Qualified Name:     org.apache.commons.httpclient.util.IdleConnectionTimeoutThread
 * JD-Core Version:    0.5.3
 */